/*
 * @lc app=leetcode.cn id=206 lang=swift
 *
 * [206] 反转链表
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     public var val: Int
 *     public var next: ListNode?
 *     public init(_ val: Int) {
 *         self.val = val
 *         self.next = nil
 *     }
 * }
 */
class Solution {
    func reverseList(_ head: ListNode?) -> ListNode? {
        // 1. 迭代
        // var prev: ListNode?
        // var curr = head
        // while curr != nil {
        //     let temp = curr?.next
        //     curr?.next = prev
        //     prev = curr
        //     curr = temp
        // }
        // return prev
        // 2.递归 1-2-3-4-5 ==> 1-(2-3-4-5) =>... => 1-2
    }
}
// @lc code=end

